package com.xcf.util;


/**
 * author ：yangchao
 * date ：2016/10/13
 * Description：
 *
 * @version V1.0
 */
public class ResponseResult<T> {

    private boolean success;
    private String code;
    private String message;
    private String token;

    private T result;

    public static ResponseResult<Object> success() {
        ResponseResult resultResp = new ResponseResult();
        resultResp.setSuccess(ResponseStatusEnum.SUCCESS.getSuccess());
        resultResp.setCode(ResponseStatusEnum.SUCCESS.getCode());
        resultResp.setMessage(ResponseStatusEnum.SUCCESS.getMsg());
        resultResp.setResult("");
        return resultResp;
    }

    public static ResponseResult<Object> success(Object result) {
        ResponseResult resultResp = new ResponseResult();
        resultResp.setSuccess(ResponseStatusEnum.SUCCESS.getSuccess());
        resultResp.setCode(ResponseStatusEnum.SUCCESS.getCode());
        resultResp.setMessage(ResponseStatusEnum.SUCCESS.getMsg());
        resultResp.setResult(result);
        return resultResp;
    }

    public static ResponseResult<Object> success(String successMsg) {
        ResponseResult resultResp = new ResponseResult();
        resultResp.setSuccess(ResponseStatusEnum.SUCCESS.getSuccess());
        resultResp.setCode(ResponseStatusEnum.SUCCESS.getCode());
        resultResp.setMessage(successMsg);
        resultResp.setResult("");
        return resultResp;
    }

    public static ResponseResult<Object> success(String sucMsg , Object result) {
        ResponseResult resultResp = new ResponseResult();
        resultResp.setSuccess(ResponseStatusEnum.SUCCESS.getSuccess());
        resultResp.setCode(ResponseStatusEnum.SUCCESS.getCode());
        resultResp.setMessage(sucMsg);
        resultResp.setResult(result);
        return resultResp;
    }

    public static ResponseResult<Object> fail() {
        ResponseResult resultResp = new ResponseResult();
        resultResp.setSuccess(ResponseStatusEnum.FAIL.getSuccess());
        resultResp.setCode(ResponseStatusEnum.FAIL.getCode());
        resultResp.setMessage(ResponseStatusEnum.FAIL.getMsg());
        resultResp.setResult("");
        return resultResp;
    }

    public static ResponseResult<Object> fail(Object result) {
        ResponseResult resultResp = new ResponseResult();
        resultResp.setSuccess(ResponseStatusEnum.FAIL.getSuccess());
        resultResp.setCode(ResponseStatusEnum.FAIL.getCode());
        resultResp.setMessage(ResponseStatusEnum.FAIL.getMsg());
        resultResp.setResult(result);
        return resultResp;
    }

    public static ResponseResult<Object> fail(String failMsg , Object result) {
        ResponseResult resultResp = new ResponseResult();
        resultResp.setSuccess(ResponseStatusEnum.FAIL.getSuccess());
        resultResp.setCode(ResponseStatusEnum.FAIL.getCode());
        resultResp.setMessage(failMsg);
        resultResp.setResult(result);
        return resultResp;
    }

    public static ResponseResult<Object> fail(String failMsg) {
        ResponseResult resultResp = new ResponseResult();
        resultResp.setSuccess(ResponseStatusEnum.FAIL.getSuccess());
        resultResp.setCode(ResponseStatusEnum.FAIL.getCode());
        resultResp.setMessage(failMsg);
        resultResp.setResult("");
        return resultResp;
    }

    public static ResponseResult<Object> result(ResponseStatusEnum statusEnum) {
        ResponseResult resultResp = new ResponseResult();
        resultResp.setSuccess(statusEnum.getSuccess());
        resultResp.setCode(statusEnum.getCode());
        resultResp.setMessage(statusEnum.getMsg());
        resultResp.setResult("");
        return resultResp;
    }

    public static ResponseResult<Object> result(ResponseStatusEnum statusEnum , Object result) {
        ResponseResult resultResp = new ResponseResult();
        resultResp.setSuccess(statusEnum.getSuccess());
        resultResp.setCode(statusEnum.getCode());
        resultResp.setMessage(statusEnum.getMsg());
        resultResp.setResult(result);
        return resultResp;
    }

    public static ResponseResult<Object> paramError(String failMsg) {
        ResponseResult resultResp = new ResponseResult();
        resultResp.setSuccess(ResponseStatusEnum.PARAM_ERROR.getSuccess());
        resultResp.setCode(ResponseStatusEnum.PARAM_ERROR.getCode());
        resultResp.setMessage(failMsg);
        resultResp.setResult("");
        return resultResp;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public String getToken() {
        return token;
    }

    public void setToken(String token) {
        this.token = token;
    }

    public T getResult() {
        return result;
    }

    public void setResult(T result) {
        this.result = result;
    }

    public boolean isSuccess() {
        return success;
    }

    public void setSuccess(boolean success) {
        this.success = success;
    }
}
